package com.zsw.controller;

import com.zsw.entity.ProductEntity;
import com.zsw.entity.RepertoryEntity;
import com.zsw.service.ProductService;
import com.zsw.service.RepertoryService;
import com.zsw.util.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;
import java.util.UUID;

@RestController
public class PreheatController {
    @Autowired
    RedisUtils redisUtils;
    @Autowired
    ProductService productService;
    @Autowired
    RepertoryService repertoryService;
    @GetMapping("/preheat/{id}")
    public void preheat(@PathVariable(value = "id",required = true) int id){
        ProductEntity entity= productService.getById(id);
        Integer pid=entity.getId();
        RepertoryEntity repertoryEntity=repertoryService.getById(pid);
//        redisUtils.set("ticketStatus", "0", 1200);
        redisUtils.set("ticket"+repertoryEntity.getId(),repertoryEntity.getProductCount().toString(),5000);
    }
}
